<template>
  <div class="assess">
    <Header></Header>
    <div class="assessMain">
      <p class="current-nav2">
        当前位置 :
        <router-link to="waitAssess2">首页</router-link>
        <i>></i>
        <a>已评审</a>
      </p>
      <div class="mianOut">
        <div class="mianInner1 pt50">
          <div class="table_title2">个人评审意见</div>
          <el-table ref="multipleTable" class="mt60" :data="opinionList">
            <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
            <el-table-column label="文件名" align="center" show-overflow-tooltip>
              <template slot-scope="scope">
                <a class="fileName">{{scope.row.reviewType|changeType}}</a>
              </template>
            </el-table-column>
            <el-table-column prop="operUser" label="操作人" align="center" width="100"></el-table-column>
            <el-table-column prop="operTime" label="操作时间" align="center" width="300"></el-table-column>
            <el-table-column label="操作" align="center" width="100">
              <template slot-scope="scope">
                <el-button class="detail-btn" @click="handleDialogShow(scope.row)">
                  <i class="el-icon-search">查看</i>
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="table_title2">评审意见汇总列表</div>
          <el-table ref="multipleTable" class="mt60" :data="summaryList">
            <el-table-column type="index" align="center" label="序号" width="50"></el-table-column>
            <el-table-column label="文件名" align="center" show-overflow-tooltip>
              <template slot-scope="scope">
                <a class="fileName">{{scope.row.reviewType|changeType}}</a>
              </template>
            </el-table-column>
            <el-table-column prop="operUser" label="操作人" align="center" width="100"></el-table-column>
            <el-table-column prop="operTime" label="操作时间" align="center" width="300"></el-table-column>
            <el-table-column label="操作" align="center" width="100">
              <template slot-scope="scope">
                <el-button class="detail-btn" @click="handleDialogShow2(scope.row)">
                  <i class="el-icon-search">查看</i>
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <Footer />
    <el-dialog title :visible.sync="assessTable" width="80%">
      <div class="ideaMain" v-if="shapeList.length>0">
        <h2 class="ideaTitle">应急预案形式评审表</h2>
        <Table1 :data='shapeList' />
      </div>
      <div class="ideaMain" v-if="factorList.length>0">
        <Table2 :data1='data1' :data2='data2' :data3='data3' />
      </div>
      <div class="ideaMain" v-if="accessoryList.length>0">
        <h2 class="ideaTitle">应急预案附件要素评审表</h2>
        <Table3 :data='accessoryList' />
      </div>
      <div class="ideaMain" v-if="gatherList.length>0">
        <h2 class="ideaTitle">应急预案个人评审意见表</h2>
        <p class="comName">单位名称：{{companyName}}</p>
        <Table4 :data='gatherList'  :suggest='suggest' :remark='remark' :signImg='signImg8' />
      </div>
    </el-dialog>
    <el-dialog title :visible.sync="assessTable2" width="80%">
      <div class="ideaMain" v-if="shapeList2.length>0">
        <h2 class="ideaTitle">应急预案形式评审表</h2>
        <Table1 :data='shapeList2' />
      </div>
      <div class="ideaMain" v-if="factorList2.length>0">
        <Table2 :data1='data1' :data2='data2' :data3='data3' />
      </div>
      <div class="ideaMain" v-if="accessoryList2.length>0">
        <h2 class="ideaTitle">应急预案附件要素评审表</h2>
        <Table3 :data='accessoryList2' />
      </div>
      <div class="ideaMain" v-if="gatherList2.length>0">
        <h2 class="ideaTitle">应急预案评审意见表</h2>
        <p class="comName">单位名称：{{companyName2}}</p>
        <Table5 :data='gatherList2'  :signImg='signImg4' />
      </div>
    </el-dialog>
  </div>
</template>
<script>
import Header from "../common/header2";
import Footer from "../common/footer";
import config from "../../config.js";
import Table1 from '../examine2/common/table1'
import Table2 from '../examine2/common/table2'
import Table3 from '../examine2/common/table3'
import Table4 from '../examine2/common/table4'
import Table5 from '../examine2/common/table5'
export default {
  components: {
    Header,
    Footer,Table1,Table2,Table3,Table4,Table5
  },
  data() {
    return {
      opinions: [],
      assessTable: false,
      assessTable2: false,
      signImg1: "",
      signImg2: "",
      signImg3: "",
      signImg4: "",
      signImgo1: "",
      signImgo2: "",
      signImgo3: "",
      companyName: "",
      companyName2: "",
      reviewTemplateName: "",
      radios: [1, 2, 3],
      opinionList: [],
      summaryList: [],
      factorList: [], 
      shapeList: [], 
      accessoryList: [], 
      gatherList: [], 
      factorList2: [], 
      shapeList2: [],
      accessoryList2: [], 
      gatherList2: [], 
      suggest2: "",
      data1:[],
      data2:[],
      data3:[],
      suggest:'',
      remark:'',
      signImg8:''
    };
  },
  created() {
    this.getOpinionList();
    this.getSummaryList();
  },
  methods: {
    getOpinionList() {
      let url = config.baseUrl + "bsReview/v1.0/review/list";
      let params = {
        planSummaryId: this.$route.query.id,
        userId: JSON.parse(localStorage.getItem("user")).id
      };
      this.$axios(url, { params: params }).then(res => {
        if (res.data.meta.success) {
          this.opinionList = res.data.data;
          this.reviewTemplateName = this.opinionList[0].reviewTemplateName;
          if(this.opinionList.length>0){
            this.opinionList.map(item=>{
              item.operTime=item.operTime.split('.')[0]
            })
          }
        } else {
          this.opinionList = [];
          this.$message.warning("个人评审意见" + res.data.meta.message);
        }
      });
    },
    getSummaryList() {
      var that = this;
      let url = config.baseUrl + "planreview/v1.0/planreview/summarylist";
      let params = {
        planSummaryId: this.$route.query.id
      };
      this.$axios(url, { params: params }).then(res => {
        if (res.data.meta.success) {
          that.summaryList = res.data.data;
        } else {
          that.summaryList = [];
        }
      });
    },
    handleDialogShow(row) {
      var that = this;
      this.assessTable = false;
      this.shapeList = [];
      this.factorList = [];
      this.accessoryList = [];
      this.gatherList = [];
      that.signImg = "";
      var reviewType = parseInt(row.reviewType);
      let url = config.baseUrl + "bsReview/v1.0/review/info";
      let url2 = config.baseUrl + "/emergency/v1.0/review/info";
      let params = {
        reviewId: row.id
      };
      let params2 = {
        planSummaryId: row.planSummaryId,
        userId: row.userId,
        tableType: row.reviewType
      };
      if (reviewType) {
        if (reviewType == 8) {
          this.$axios
            .post(url2, params2)
            .then(res => {
              if (res.data.meta.success) {

                res.data.data.list.map((item)=>{
                      this.suggest = item.opinion
                      this.remark=item.remarks
                      this.signImg8 = [item.url]
                })
                that.gatherList = res.data.data.list;
                that.companyName = res.data.data.companyName;
                console.log(this.signImg8)
                if (that.gatherList.length) {
                  that.assessTable = true;
                  that.signImg = that.gatherList[0].autograph;
                }
              } else {
                that.$message.warning(res.data.meta.message);
              }
            })
            .catch(response => {
              console.log(response);
            });
        } else {
          this.$axios(url, { params: params })
            .then(res => {
              if (res.data.meta.success) {
                this["signImgo" + row.reviewType] = res.data.data.autograph;
                 if(res.data.data.list.length>0){
                    res.data.data.list.map((item,index)=>{
                      item.result=item.selectResult
                    })
                  }
                if (reviewType == 5) {
                 
                res.data.data.list.push({
                  reviewContent: [res.data.data.autograph],
                  reviewItemOne: "评审专家签字",
                  reviewMethod: "",
                  tableType: "5",
                  flag:0,
                })
                  that.shapeList = res.data.data.list;

                  that.signImg = res.data.data.autograph;
                } else if (reviewType == 6) {
                 
                  var obj = {
                    reviewContent: [res.data.data.autograph],
                    reviewItemOne: "评审专家签字",
                    reviewMethod: "",
                    tableType: "6",
                    flag:0,
                  }
                  this.data1 = res.data.data.list.splice(0,20)
                  this.data2 = res.data.data.list.splice(0,10)
                  this.data3 = res.data.data.list
               
                    this.data1.push({
                        reviewContent : '',
                        reviewItemOne: "注：“＊”代表应急预案的关键要素。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data2.push({
                      reviewContent: '',
                      reviewItemOne: "注：“＊”代表应急预案的关键要素。如果专项应急预案作为综合应急预案的附件，综合应急预案已经明确的要素，专项应急预案可省略。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data3.push({
                      reviewContent: '',
                      reviewItemOne: "注：“＊”代表应急预案的关键要素。现场处置方案落实到岗位每个人，可以只保留应急处置。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data1.push(obj)
                    this.data2.push(obj)
                    this.data3.push(obj)    

                  that.factorList = res.data.data.list;
                  that.signImg = res.data.data.autograph;
                } else if (reviewType == 7) {
                 
                 res.data.data.list.push({
                   reviewContent: '',
                   reviewItemOne: "注：附件根据应急工作需要而设置，部分项目可省略。",
                    reviewMethod: "",
                    tableType: "6",
                    flag:1,
                })
                res.data.data.list.push({
                  reviewContent: [res.data.data.autograph],
                  reviewItemOne: "评审专家签字",
                  reviewMethod: "",
                  tableType: "7",
                  flag:0,
                })
                  that.accessoryList = res.data.data.list;
                  that.signImg = res.data.data.autograph;
                }
                if (
                  that.shapeList.length ||
                  that.factorList.length ||
                  that.accessoryList.length
                ) {
                  that.assessTable = true;
                }
              } else {
                that.$message.warning(res.data.meta.message);
              }
            })
            .catch(response => {
              console.log(response);
            });
        }
      }
    },
    handleDialogShow2(row) {
      var that = this;
      this.assessTable2 = false;
      this.shapeList2 = [];
      this.factorList2 = [];
      this.accessoryList2 = [];
      this.gatherList2 = [];
      var reviewType = parseInt(row.reviewType);
      let url = config.baseUrl + "bsReview/v1.0/review/summaryInfoByType";
      let url2 = config.baseUrl + "emergency/v1.0/review/look?id=" + row.id;
      let params = {
        planSummaryId: row.planSummaryId,
        reviewType: row.reviewType
      };
      if (reviewType) {
        if (reviewType == 8) {
          this.$axios
            .post(url2)
            .then(res => {
              if (res.data.meta.success) {
                this.signImg4 = res.data.data.url;
                that.gatherList2 = res.data.data.list;
                that.companyName2 = res.data.data.list[0].companyName;
                if (that.gatherList2.length) {
                  that.assessTable2 = true;
                }
                this.suggest2 = res.data.data.list[0].opinion;
              } else {
                that.$message.warning(res.data.meta.message);
              }
            })
        } else {
          this.$axios(url, { params: params })
            .then(res => {
              if (res.data.meta.success) {
                 if(res.data.data.list.length>0){
                    res.data.data.list.map((item,index)=>{
                      item.result=item.selectResult
                    })
                  }
                this["signImg" + row.reviewType] = res.data.data.url;
                if (reviewType == 5) {
                res.data.data.list.push({
                  reviewContent: res.data.data.url,
                  reviewItemOne: "评审专家签字",
                  reviewMethod: "",
                  tableType: "5",
                  flag:0,
                })
                  that.shapeList2 = res.data.data.list;
                } else if (reviewType == 6) {
                  var obj = {
                    reviewContent: res.data.data.url,
                    reviewItemOne: "评审专家签字",
                    reviewMethod: "",
                    tableType: "6",
                    flag:0,
                  }
                  this.data1 = res.data.data.list.splice(0,20)
                  this.data2 = res.data.data.list.splice(0,10)
                  this.data3 = res.data.data.list
               
                    this.data1.push({
                        reviewContent : '',
                        reviewItemOne: "注：“＊”代表应急预案的关键要素。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data2.push({
                      reviewContent: '',
                      reviewItemOne: "注：“＊”代表应急预案的关键要素。如果专项应急预案作为综合应急预案的附件，综合应急预案已经明确的要素，专项应急预案可省略。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data3.push({
                      reviewContent: '',
                      reviewItemOne: "注：“＊”代表应急预案的关键要素。现场处置方案落实到岗位每个人，可以只保留应急处置。",
                        reviewMethod: "",
                        tableType: "6",
                        flag:1,
                    })
                    this.data1.push(obj)
                    this.data2.push(obj)
                    this.data3.push(obj)    

                  that.factorList2 = res.data.data.list;
                } else if (reviewType == 7) {
                   res.data.data.list.push({
                   reviewContent: '',
                   reviewItemOne: "注：附件根据应急工作需要而设置，部分项目可省略。",
                    reviewMethod: "",
                    tableType: "6",
                    flag:1,
                })
                res.data.data.list.push({
                  reviewContent: res.data.data.url,
                  reviewItemOne: "评审专家签字",
                  reviewMethod: "",
                  tableType: "7",
                  flag:0,
                })
                  that.accessoryList2 = res.data.data.list;
                }
                if (
                  that.shapeList2.length ||
                  that.factorList2.length ||
                  that.accessoryList2.length
                ) {
                  that.assessTable2 = true;
                }
              } else {
                that.$message.warning(res.data.meta.message);
              }
            })
        }
      }
    }
  },
  filters: {
    changeType(val) {
      console.log(val)
      if (!val) {
        return "";
      }
      if (val == 5) {
        return "应急预案形式评审表";
      } else if (val == 6) {
        return "应急预案要素评审表";
      } else if (val == 7) {
        return "应急预案附件要素评审表";
      } else if (val == 8) {
        return "评审意见表";
      }
    }
  }
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less'>
@import "../../../static/css/assess.less";
.assess .el-textarea__inner{
  cursor: default;
}
.radioImg{
  width:25px;
  height:25px;
}
.el-table{
          border-color:#ddd;
          td{
          color: #000;
          padding: 6px 0;
          text-align: center;
          p{
            margin:10px 0;
          }
        }
        }
       .ideaMain{
.el-table thead.is-group th{
          color: rgb(51, 51, 51);
    font-weight: bold;
    line-height: 40px;
    }
       }  
</style>
<style scoped >
 .div-radio1,.div-radio2,p,tr,td{
  cursor: default;
}
</style>


